<template>
  <div>
    <span>{{ num }}</span>
    <button @click="increment">+</button>
  </div>
</template>

<script lang='ts'>
import { defineComponent } from 'vue'
export default defineComponent({
  data() {
    return {
      num: 0
    }
  },
  methods: {
    increment() {
      this.num++
    }
  },
  watch: {
    num: {
      handler(newval, oldval) {
        console.log(newval, oldval);
      },
      immediate:true
    }
  }
})
</script>

<style lang='scss' scoped></style>